﻿using Hotel.DAL;
using Hotel.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel.BLL
{
    public class ShopBLL
    {
        public ShopBLL(ShopDAL shopDAL)
        {
            ShopDAL = shopDAL;
        }

        public ShopDAL ShopDAL { get; }


        /// <summary>
        /// 添加门店
        /// </summary>
        /// <param name="shopModel"></param>
        /// <returns></returns>
        public int ShopAdd(ShopModel shopModel)
        {
            int res = ShopDAL.SearchShopName(shopModel.ShopName);
            if (res > 0)
            {
                return -1;//重复

            }
            else
            {
                int r = ShopDAL.ShopAdd(shopModel);
                if (r > 0)
                {
                    return 1;//成功

                }
                else
                {
                    return -2;
                }
            }


        }




        /// <summary>
        ///  门店列表
        /// </summary>
        /// <param name="count">总条数</param>
        /// <param name="page">总页码</param>
        /// <param name="rightName">名称</param>
        /// <param name="createtiem">时间</param>
        /// <param name="index">页码</param>
        /// <param name="size">页容量</param>
        /// <returns></returns>
        public List<ShopModel> GetShopList(out int count, out int page, string? shopName = "", int index = 1, int size = 2)
        {
            List<ShopModel> list = ShopDAL.GetShopList(out count, out page, shopName, index, size);
            return list;

        }




        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public int DelAllShopItem(string ids)
        {
            var res = ShopDAL.DelAllShopItem(ids);
            if (res > 0)
            {

                return 1;//成功
            }
            else
            {

                return -2;//失败
            }
        }







        /// <summary>
        /// 批量上下架
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public int UpOrDownAllShowItem(string ids, int state)
        {

          int res= ShopDAL.UpOrDownAllShowItem(ids, state);
            if (res>0)
            {
                return 1;//成功
            }
            else
            {

                return -2;//失败
            }

        }























    }
}
